<template>
  <div class="container">
    <div class="wrapper">
      <swiper :options="swiperOption">
        <swiper-slide
          v-for="(item, index) in imgs"
          :key="index"
        >
          <div class="swiper-zoom-container">
            <img class="swiper-image" :src="item" alt="">
          </div>
        </swiper-slide>
        <div class="swiper-pagination" slot="pagination" v-if="showPagination"></div>
      </swiper>
    </div>
    <div class="cancleButton" @click="closeGallary">
      <mu-icon value="close" color="#ffffff" size="36"></mu-icon>
    </div>
  </div>
</template>

<script>
export default {
  name: 'CommonGallary',
  props: {
    imgs: {
      type: Array
    },
    showPagination: {
      default: true
    }
  },
  data () {
    return {
      swiperOption: {
        pagination: {
          el: '.swiper-pagination',
          type: 'fraction'
        },
        observer: true,
        observeParents: true,
        spaceBetween: 10,
        zoom: {
          maxRatio: 2
        }
      }
    }
  },
  methods: {
    closeGallary () {
      this.$emit('close')
    }
  }
}
</script>

<style lang="stylus" scoped>
  .container >>> .swiper-container
    overflow: inherit
  .container
    position: fixed
    left: 0
    top: 0
    right: 0
    bottom: 0
    background-color: #000
    z-index: 102
    display: flex
    flex-direction: column
    justify-content: center
    padding: 0
    .wrapper
      width: 100%
      height: 0
      padding-bottom: 71%
      .swiper-image
        width: 100%
    .swiper-pagination
      color: #fff
      bottom: -.75rem
    .cancleButton
      position: absolute
      bottom: 1.25rem
      left: 50%
      transform: translateX(-50%)
      width: .96rem
      height: .96rem
      border: 2px solid #fff
      border-radius: 50%
      opacity: .6
      text-align: center
      z-index: 111
      .material-icons
        line-height: 1.25
</style>
